﻿using System.IO;
using System.Reflection;
using System.Text;

namespace TfsRollUp.ProjectHelper
{
    class Program
    {
        /// <summary>
        /// Read version number from TfsRollUp.Client, and send it to Wix
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var self = Assembly.GetAssembly(typeof(Program));
            var version = self.GetName().Version;
            // ProjectHelper is executed from TfsRollUp.Setup
            var wixFile = new FileInfo(@"..\..\Version.wxi");
            var wixContent = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><Include><?define Version = \"{0}.{1}.{2}.{3}\" ?></Include>", version.Major, version.Minor, version.Build, version.Revision);
            File.WriteAllText(wixFile.FullName, wixContent);
        }
    }
}
